Question 2

library(palaeoSig)
## Loading required package: vegan
## Loading required package: permute
## Loading required package: lattice
## This is vegan 2.5-2
library(vegan)
library(analogue)
## analogue version 0.17-0
library(rioja)
## This is rioja 0.9-15.1
## 
## Attaching package: 'rioja'
## The following objects are masked from 'package:analogue':
## 
##     crossval, performance
data(arctic.pollen)
data("arctic.env")
arctic_sqrt <- sqrt(arctic.pollen)
arctic_cca_tmin <- vegan::cca(arctic_sqrt ~ arctic.env$tmin)
arctic_cca_tmin_sum <- summary(arctic_cca_tmin)
arctic_cca_tmin_sum$cont
## $importance
## Importance of components:
##                          CCA1    CA1    CA2     CA3     CA4     CA5
## Eigenvalue            0.03753 0.2435 0.1348 0.06629 0.04657 0.03796
## Proportion Explained  0.03290 0.2134 0.1182 0.05810 0.04081 0.03327
## Cumulative Proportion 0.03290 0.2463 0.3644 0.42255 0.46336 0.49663
##                           CA6     CA7     CA8     CA9    CA10    CA11
## Eigenvalue            0.03694 0.03355 0.03299 0.02860 0.02816 0.02608
## Proportion Explained  0.03238 0.02940 0.02892 0.02506 0.02468 0.02286
## Cumulative Proportion 0.52901 0.55841 0.58733 0.61240 0.63707 0.65994
##                          CA12    CA13    CA14    CA15    CA16    CA17
## Eigenvalue            0.02509 0.02339 0.02246 0.02088 0.02027 0.01894
## Proportion Explained  0.02199 0.02050 0.01969 0.01831 0.01777 0.01660
## Cumulative Proportion 0.68192 0.70242 0.72211 0.74041 0.75818 0.77478
##                          CA18    CA19    CA20    CA21    CA22    CA23
## Eigenvalue            0.01854 0.01800 0.01721 0.01609 0.01584 0.01457
## Proportion Explained  0.01625 0.01578 0.01508 0.01411 0.01388 0.01277
## Cumulative Proportion 0.79103 0.80680 0.82188 0.83599 0.84987 0.86264
##                          CA24    CA25    CA26    CA27    CA28     CA29
## Eigenvalue            0.01369 0.01296 0.01285 0.01252 0.01158 0.011311
## Proportion Explained  0.01200 0.01136 0.01126 0.01097 0.01015 0.009914
## Cumulative Proportion 0.87464 0.88600 0.89726 0.90824 0.91839 0.928299
##                           CA30     CA31     CA32     CA33     CA34
## Eigenvalue            0.010854 0.010533 0.010087 0.009837 0.009288
## Proportion Explained  0.009513 0.009232 0.008841 0.008622 0.008141
## Cumulative Proportion 0.937812 0.947044 0.955885 0.964507 0.972648
##                           CA35     CA36     CA37     CA38
## Eigenvalue            0.008369 0.008206 0.007512 0.007119
## Proportion Explained  0.007336 0.007193 0.006584 0.006240
## Cumulative Proportion 0.979984 0.987176 0.993760 1.000000
arctic_cca_tmax <- vegan::cca(arctic_sqrt ~ arctic.env$tmax)
arctic_cca_tmax_sum <- summary(arctic_cca_tmax)
arctic_cca_tmax_sum$cont
## $importance
## Importance of components:
##                         CCA1    CA1     CA2     CA3     CA4     CA5
## Eigenvalue            0.1761 0.1438 0.08789 0.07051 0.05173 0.04362
## Proportion Explained  0.1544 0.1260 0.07703 0.06180 0.04534 0.03823
## Cumulative Proportion 0.1544 0.2804 0.35741 0.41921 0.46455 0.50279
##                           CA6     CA7     CA8     CA9    CA10    CA11
## Eigenvalue            0.03428 0.03372 0.03234 0.02878 0.02632 0.02572
## Proportion Explained  0.03005 0.02956 0.02834 0.02523 0.02307 0.02255
## Cumulative Proportion 0.53284 0.56239 0.59074 0.61597 0.63904 0.66158
##                          CA12    CA13    CA14    CA15    CA16    CA17
## Eigenvalue            0.02450 0.02333 0.02155 0.02099 0.02059 0.01910
## Proportion Explained  0.02147 0.02045 0.01889 0.01840 0.01805 0.01674
## Cumulative Proportion 0.68305 0.70350 0.72239 0.74079 0.75884 0.77557
##                          CA18    CA19    CA20    CA21    CA22    CA23
## Eigenvalue            0.01862 0.01777 0.01720 0.01632 0.01539 0.01462
## Proportion Explained  0.01632 0.01558 0.01508 0.01430 0.01349 0.01281
## Cumulative Proportion 0.79189 0.80747 0.82254 0.83685 0.85034 0.86315
##                          CA24    CA25    CA26    CA27    CA28     CA29
## Eigenvalue            0.01339 0.01323 0.01285 0.01238 0.01154 0.011309
## Proportion Explained  0.01173 0.01160 0.01126 0.01085 0.01012 0.009912
## Cumulative Proportion 0.87488 0.88648 0.89774 0.90859 0.91871 0.928621
##                           CA30     CA31     CA32     CA33     CA34
## Eigenvalue            0.010956 0.010457 0.009957 0.009545 0.009274
## Proportion Explained  0.009603 0.009165 0.008727 0.008366 0.008128
## Cumulative Proportion 0.938224 0.947389 0.956116 0.964482 0.972610
##                           CA35     CA36     CA37     CA38
## Eigenvalue            0.008495 0.008258 0.007549 0.006948
## Proportion Explained  0.007446 0.007238 0.006617 0.006090
## Cumulative Proportion 0.980055 0.987293 0.993910 1.000000
arctic_cca_pann <- vegan::cca(arctic_sqrt ~ arctic.env$ptotal)
arctic_cca_pann_sum <- summary(arctic_cca_pann)
arctic_cca_pann_sum$cont
## $importance
## Importance of components:
##                          CCA1    CA1    CA2     CA3     CA4     CA5
## Eigenvalue            0.06729 0.2131 0.1354 0.06644 0.04646 0.04140
## Proportion Explained  0.05898 0.1868 0.1187 0.05824 0.04072 0.03629
## Cumulative Proportion 0.05898 0.2458 0.3644 0.42265 0.46337 0.49966
##                           CA6     CA7     CA8     CA9   CA10    CA11
## Eigenvalue            0.03546 0.03375 0.03283 0.02903 0.0275 0.02614
## Proportion Explained  0.03108 0.02958 0.02877 0.02545 0.0241 0.02291
## Cumulative Proportion 0.53074 0.56033 0.58910 0.61455 0.6386 0.66156
##                          CA12    CA13    CA14    CA15    CA16    CA17
## Eigenvalue            0.02483 0.02317 0.02263 0.02085 0.01966 0.01880
## Proportion Explained  0.02176 0.02031 0.01984 0.01827 0.01723 0.01648
## Cumulative Proportion 0.68332 0.70363 0.72347 0.74174 0.75897 0.77545
##                          CA18    CA19    CA20    CA21    CA22    CA23
## Eigenvalue            0.01819 0.01792 0.01721 0.01622 0.01566 0.01440
## Proportion Explained  0.01595 0.01571 0.01508 0.01421 0.01372 0.01262
## Cumulative Proportion 0.79139 0.80710 0.82218 0.83640 0.85012 0.86274
##                          CA24    CA25    CA26    CA27    CA28     CA29
## Eigenvalue            0.01372 0.01317 0.01284 0.01248 0.01178 0.011297
## Proportion Explained  0.01203 0.01155 0.01126 0.01094 0.01032 0.009902
## Cumulative Proportion 0.87477 0.88632 0.89758 0.90851 0.91884 0.928737
##                           CA30     CA31     CA32     CA33     CA34
## Eigenvalue            0.010712 0.010471 0.010102 0.009840 0.009272
## Proportion Explained  0.009389 0.009178 0.008854 0.008624 0.008126
## Cumulative Proportion 0.938126 0.947304 0.956158 0.964782 0.972909
##                           CA35     CA36     CA37     CA38
## Eigenvalue            0.008308 0.007962 0.007548 0.007091
## Proportion Explained  0.007282 0.006978 0.006616 0.006215
## Cumulative Proportion 0.980191 0.987169 0.993785 1.000000

tmax explains the most variance, because the ratio of CCA1/CA1 is the highest,

arctic_cca_tjul <- vegan::cca(arctic_sqrt ~ arctic.env$tjul)
arctic_cca_tjul_sum <- summary(arctic_cca_tjul)
arctic_cca_tjul_sum$cont
## $importance
## Importance of components:
##                         CCA1    CA1     CA2     CA3     CA4     CA5
## Eigenvalue            0.1530 0.1547 0.09566 0.07269 0.05484 0.04373
## Proportion Explained  0.1341 0.1356 0.08384 0.06371 0.04806 0.03832
## Cumulative Proportion 0.1341 0.2697 0.35349 0.41720 0.46527 0.50359
##                           CA6     CA7     CA8     CA9    CA10    CA11
## Eigenvalue            0.03706 0.03312 0.03183 0.02889 0.02617 0.02573
## Proportion Explained  0.03248 0.02903 0.02790 0.02532 0.02293 0.02256
## Cumulative Proportion 0.53607 0.56510 0.59300 0.61832 0.64126 0.66381
##                          CA12    CA13    CA14    CA15    CA16    CA17
## Eigenvalue            0.02362 0.02275 0.02196 0.02068 0.02044 0.01879
## Proportion Explained  0.02071 0.01994 0.01925 0.01813 0.01792 0.01647
## Cumulative Proportion 0.68452 0.70446 0.72370 0.74183 0.75975 0.77622
##                          CA18    CA19    CA20    CA21    CA22    CA23
## Eigenvalue            0.01862 0.01791 0.01711 0.01633 0.01488 0.01449
## Proportion Explained  0.01632 0.01570 0.01500 0.01431 0.01304 0.01270
## Cumulative Proportion 0.79254 0.80823 0.82323 0.83754 0.85058 0.86329
##                          CA24    CA25    CA26    CA27     CA28     CA29
## Eigenvalue            0.01352 0.01317 0.01281 0.01239 0.011328 0.011098
## Proportion Explained  0.01185 0.01154 0.01123 0.01086 0.009929 0.009727
## Cumulative Proportion 0.87514 0.88668 0.89791 0.90877 0.918695 0.928422
##                           CA30     CA31     CA32     CA33     CA34
## Eigenvalue            0.010939 0.010493 0.010011 0.009552 0.009149
## Proportion Explained  0.009587 0.009197 0.008775 0.008372 0.008018
## Cumulative Proportion 0.938009 0.947207 0.955981 0.964354 0.972372
##                           CA35     CA36     CA37     CA38
## Eigenvalue            0.008627 0.008251 0.007549 0.007094
## Proportion Explained  0.007561 0.007232 0.006617 0.006218
## Cumulative Proportion 0.979933 0.987166 0.993782 1.000000
arctic_cca_tjan <- vegan::cca(arctic_sqrt ~ arctic.env$tjan)
arctic_cca_tjul_sum <- summary(arctic_cca_tjul)
arctic_cca_tjul_sum$cont
## $importance
## Importance of components:
##                         CCA1    CA1     CA2     CA3     CA4     CA5
## Eigenvalue            0.1530 0.1547 0.09566 0.07269 0.05484 0.04373
## Proportion Explained  0.1341 0.1356 0.08384 0.06371 0.04806 0.03832
## Cumulative Proportion 0.1341 0.2697 0.35349 0.41720 0.46527 0.50359
##                           CA6     CA7     CA8     CA9    CA10    CA11
## Eigenvalue            0.03706 0.03312 0.03183 0.02889 0.02617 0.02573
## Proportion Explained  0.03248 0.02903 0.02790 0.02532 0.02293 0.02256
## Cumulative Proportion 0.53607 0.56510 0.59300 0.61832 0.64126 0.66381
##                          CA12    CA13    CA14    CA15    CA16    CA17
## Eigenvalue            0.02362 0.02275 0.02196 0.02068 0.02044 0.01879
## Proportion Explained  0.02071 0.01994 0.01925 0.01813 0.01792 0.01647
## Cumulative Proportion 0.68452 0.70446 0.72370 0.74183 0.75975 0.77622
##                          CA18    CA19    CA20    CA21    CA22    CA23
## Eigenvalue            0.01862 0.01791 0.01711 0.01633 0.01488 0.01449
## Proportion Explained  0.01632 0.01570 0.01500 0.01431 0.01304 0.01270
## Cumulative Proportion 0.79254 0.80823 0.82323 0.83754 0.85058 0.86329
##                          CA24    CA25    CA26    CA27     CA28     CA29
## Eigenvalue            0.01352 0.01317 0.01281 0.01239 0.011328 0.011098
## Proportion Explained  0.01185 0.01154 0.01123 0.01086 0.009929 0.009727
## Cumulative Proportion 0.87514 0.88668 0.89791 0.90877 0.918695 0.928422
##                           CA30     CA31     CA32     CA33     CA34
## Eigenvalue            0.010939 0.010493 0.010011 0.009552 0.009149
## Proportion Explained  0.009587 0.009197 0.008775 0.008372 0.008018
## Cumulative Proportion 0.938009 0.947207 0.955981 0.964354 0.972372
##                           CA35     CA36     CA37     CA38
## Eigenvalue            0.008627 0.008251 0.007549 0.007094
## Proportion Explained  0.007561 0.007232 0.006617 0.006218
## Cumulative Proportion 0.979933 0.987166 0.993782 1.000000
varpart(arctic_sqrt, arctic.env$tjul, arctic.env$tjan)
## 
## Partition of variance in RDA 
## 
## Call: varpart(Y = arctic_sqrt, X = arctic.env$tjul,
## arctic.env$tjan)
## 
## Explanatory tables:
## X1:  arctic.env$tjul
## X2:  arctic.env$tjan 
## 
## No. of explanatory tables: 2 
## Total variation (SS): 22419 
##             Variance: 27.109 
## No. of observations: 828 
## 
## Partition table:
##                      Df R.squared Adj.R.squared Testable
## [a+b] = X1            1   0.22897       0.22804     TRUE
## [b+c] = X2            1   0.03129       0.03012     TRUE
## [a+b+c] = X1+X2       2   0.27042       0.26865     TRUE
## Individual fractions                                    
## [a] = X1|X2           1                 0.23853     TRUE
## [b]                   0                -0.01049    FALSE
## [c] = X2|X1           1                 0.04061     TRUE
## [d] = Residuals                         0.73135    FALSE
## ---
## Use function 'rda' to test significance of fractions of interest

The shared variance explained for July and January temperature is 26.8%  The variance explained by July temp is 22.9 percent and by January temp is 3.1%.

arctic_cca_climate <- vegan::cca(arctic_sqrt ~ arctic.env$tjan + arctic.env$tjul + arctic.env$ptotal + arctic.env$sjul)
arctic_cca_clim_sum <- summary(arctic_cca_climate)
arctic_cca_clim_sum$cont
## $importance
## Importance of components:
##                         CCA1    CCA2    CCA3    CCA4     CA1     CA2
## Eigenvalue            0.1862 0.06987 0.02958 0.01459 0.08071 0.06992
## Proportion Explained  0.1632 0.06124 0.02593 0.01278 0.07074 0.06128
## Cumulative Proportion 0.1632 0.22446 0.25039 0.26317 0.33391 0.39520
##                           CA3     CA4     CA5     CA6     CA7     CA8
## Eigenvalue            0.06444 0.04416 0.03502 0.03424 0.03244 0.03084
## Proportion Explained  0.05648 0.03870 0.03069 0.03001 0.02843 0.02703
## Cumulative Proportion 0.45168 0.49038 0.52107 0.55108 0.57952 0.60655
##                           CA9    CA10    CA11    CA12    CA13    CA14
## Eigenvalue            0.02685 0.02568 0.02485 0.02264 0.02253 0.02110
## Proportion Explained  0.02354 0.02251 0.02178 0.01985 0.01974 0.01849
## Cumulative Proportion 0.63008 0.65259 0.67437 0.69422 0.71396 0.73246
##                          CA15    CA16    CA17    CA18    CA19    CA20
## Eigenvalue            0.01942 0.01872 0.01835 0.01775 0.01709 0.01666
## Proportion Explained  0.01702 0.01641 0.01608 0.01556 0.01498 0.01460
## Cumulative Proportion 0.74948 0.76589 0.78198 0.79753 0.81251 0.82711
##                          CA21    CA22    CA23    CA24    CA25    CA26
## Eigenvalue            0.01564 0.01446 0.01440 0.01330 0.01278 0.01265
## Proportion Explained  0.01371 0.01268 0.01262 0.01165 0.01120 0.01108
## Cumulative Proportion 0.84082 0.85349 0.86611 0.87776 0.88897 0.90005
##                          CA27     CA28     CA29     CA30     CA31     CA32
## Eigenvalue            0.01199 0.011282 0.010955 0.010515 0.010442 0.009709
## Proportion Explained  0.01051 0.009889 0.009602 0.009216 0.009152 0.008510
## Cumulative Proportion 0.91056 0.920444 0.930046 0.939262 0.948414 0.956924
##                           CA33     CA34     CA35     CA36     CA37
## Eigenvalue            0.009536 0.009113 0.008251 0.007829 0.007474
## Proportion Explained  0.008358 0.007988 0.007232 0.006862 0.006550
## Cumulative Proportion 0.965282 0.973270 0.980501 0.987363 0.993913
##                           CA38
## Eigenvalue            0.006945
## Proportion Explained  0.006087
## Cumulative Proportion 1.000000

January and July temperatures, annual precipitation and July sunshine explain 39.6% of the variance in the arctic pollen dataset.

# Creates triplot with temperature 
plot(arctic_cca_climate)

# Adds ordination for each environmental variable
vegan::ordisurf(x = arctic_cca_climate, arctic.env$tjan)

## 
## Family: gaussian 
## Link function: identity 
## 
## Formula:
## y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
## 
## Estimated degrees of freedom:
## 8.58  total = 9.58 
## 
## REML score: 2522.47
vegan::ordisurf(x = arctic_cca_climate, arctic.env$tjul)

## 
## Family: gaussian 
## Link function: identity 
## 
## Formula:
## y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
## 
## Estimated degrees of freedom:
## 8.84  total = 9.84 
## 
## REML score: 1699.555
vegan::ordisurf(x = arctic_cca_climate, arctic.env$ptotal)

## 
## Family: gaussian 
## Link function: identity 
## 
## Formula:
## y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
## 
## Estimated degrees of freedom:
## 8.5  total = 9.5 
## 
## REML score: 5803.674
vegan::ordisurf(x = arctic_cca_climate, arctic.env$sjul)

## 
## Family: gaussian 
## Link function: identity 
## 
## Formula:
## y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
## 
## Estimated degrees of freedom:
## 8.55  total = 9.55 
## 
## REML score: 2395.364

All the variables are explaining different directions of variance in the data. The july temperature and total precipitation point in approximately the same direction. January and July temperature are also relatively close.

Question 3

# Subsets 4 species of interest from arctic pollen data
subset <- arctic.pollen[,c(13,7,25,26)]

# Estimate WA optima and tolerances for chosen taxa
subset_optima <- analogue::optima(subset, arctic.env$tjul)
subset_tolerance <- tolerance(subset, arctic.env$tjul)

# Plots abundances of taxa as function of July temp with unimodal response
plot(arctic.env$tjul, arctic.pollen[,c(13)], xlab = 'F.CYPE Abundance')
lines(arctic.env$tjul,(dnorm(arctic.env$tjul,subset_optima[1],subset_tolerance[1])*100))

plot(arctic.env$tjul, arctic.pollen[,c(7)], xlab = 'F.PPIN Abundance')
lines(arctic.env$tjul,(dnorm(arctic.env$tjul,subset_optima[2],subset_tolerance[2])*100))

plot(arctic.env$tjul, arctic.pollen[,c(25)], xlab = 'F.PPIN Abundance')
lines(arctic.env$tjul,(dnorm(arctic.env$tjul,subset_optima[3],subset_tolerance[3])*100))

plot(arctic.env$tjul, arctic.pollen[,c(26)], xlab = 'F.PPIN Abundance')
lines(arctic.env$tjul,(dnorm(arctic.env$tjul,subset_optima[4],subset_tolerance[4])*100))

# Runs WA and summarizes results
arctic_WA <- rioja::WA(arctic_sqrt, arctic.env$tjul)
arctic_WA_sum <- summary(arctic_WA)
## 
## Method : Weighted Averaging
## Call   : rioja::WA(y = arctic_sqrt, x = arctic.env$tjul) 
## 
## Tolerance DW       : No 
## Monotonic deshrink : No 
## No. samples        : 828 
## No. species        : 39 
## Cross val.         : none 
## 
## Deshrinking regression coefficients:
##       Inverse d/s Classical d/s
## wa.b0    -29.6874        8.1298
## wa.b1      4.1067        0.1526
## 
## Performance:
##           RMSE      R2  Avg.Bias  Max.Bias    Skill
## WA.inv  2.1638  0.6268         0    5.1059  62.6822
## WA.cla  2.7331  0.6268         0    3.3543  40.4652
## 
## 
## Fitted values
##        WA.inv    WA.cla
## 1    9.716231  9.599130
## 2    8.292863  7.328364
## 3    8.351207  7.421443
## .           .         .
## .           .         .
## 831  9.525978  9.295611
## 
## Species coefficients
##           Optima
## F.PABI 12.307671
## F.BALN 10.490190
## F.CAMB  9.389703
## .              .
## .              .
## F.ULMA 12.812432
# Estimates July temperature optima for all taxa in the arctic pollen dataset 
arctic_optima <- analogue::optima(arctic.pollen, arctic.env$tjul)

plot(arctic_optima, arctic_cca_tjul$CCA$v)

The Arctic pollen optima line up quite well with the species scores calculated for the CCA.

# Predict July temperatures
arctic_WA_predict <- predict(arctic_WA)

# Compares predicted July temps to CCA site scores
plot(arctic_cca_tjul$CCA$u, arctic_WA_predict[,1])

There’s a reasonably strong correlation between the CCA site scores and the WA predicted July temperatures

# Compare apparent and cross-validated (crossval(my.wa.model)) predictions of July temperature. Also compare performance statistics (performance(my.cv.wa.model)).
arctic_WA_cv <- rioja::crossval(arctic_WA)
## Cross-validating:
## 
  |                                                                       
  |                                                                 |   0%
  |                                                                       
  |                                                                 |   1%
  |                                                                       
  |=                                                                |   1%
  |                                                                       
  |=                                                                |   2%
  |                                                                       
  |==                                                               |   2%
  |                                                                       
  |==                                                               |   3%
  |                                                                       
  |==                                                               |   4%
  |                                                                       
  |===                                                              |   4%
  |                                                                       
  |===                                                              |   5%
  |                                                                       
  |====                                                             |   5%
  |                                                                       
  |====                                                             |   6%
  |                                                                       
  |====                                                             |   7%
  |                                                                       
  |=====                                                            |   7%
  |                                                                       
  |=====                                                            |   8%
  |                                                                       
  |======                                                           |   9%
  |                                                                       
  |======                                                           |  10%
  |                                                                       
  |=======                                                          |  10%
  |                                                                       
  |=======                                                          |  11%
  |                                                                       
  |========                                                         |  12%
  |                                                                       
  |========                                                         |  13%
  |                                                                       
  |=========                                                        |  13%
  |                                                                       
  |=========                                                        |  14%
  |                                                                       
  |=========                                                        |  15%
  |                                                                       
  |==========                                                       |  15%
  |                                                                       
  |==========                                                       |  16%
  |                                                                       
  |===========                                                      |  16%
  |                                                                       
  |===========                                                      |  17%
  |                                                                       
  |===========                                                      |  18%
  |                                                                       
  |============                                                     |  18%
  |                                                                       
  |============                                                     |  19%
  |                                                                       
  |=============                                                    |  19%
  |                                                                       
  |=============                                                    |  20%
  |                                                                       
  |=============                                                    |  21%
  |                                                                       
  |==============                                                   |  21%
  |                                                                       
  |==============                                                   |  22%
  |                                                                       
  |===============                                                  |  22%
  |                                                                       
  |===============                                                  |  23%
  |                                                                       
  |===============                                                  |  24%
  |                                                                       
  |================                                                 |  24%
  |                                                                       
  |================                                                 |  25%
  |                                                                       
  |=================                                                |  25%
  |                                                                       
  |=================                                                |  26%
  |                                                                       
  |=================                                                |  27%
  |                                                                       
  |==================                                               |  27%
  |                                                                       
  |==================                                               |  28%
  |                                                                       
  |===================                                              |  29%
  |                                                                       
  |===================                                              |  30%
  |                                                                       
  |====================                                             |  30%
  |                                                                       
  |====================                                             |  31%
  |                                                                       
  |====================                                             |  32%
  |                                                                       
  |=====================                                            |  32%
  |                                                                       
  |=====================                                            |  33%
  |                                                                       
  |======================                                           |  33%
  |                                                                       
  |======================                                           |  34%
  |                                                                       
  |======================                                           |  35%
  |                                                                       
  |=======================                                          |  35%
  |                                                                       
  |=======================                                          |  36%
  |                                                                       
  |========================                                         |  36%
  |                                                                       
  |========================                                         |  37%
  |                                                                       
  |========================                                         |  38%
  |                                                                       
  |=========================                                        |  38%
  |                                                                       
  |=========================                                        |  39%
  |                                                                       
  |==========================                                       |  39%
  |                                                                       
  |==========================                                       |  40%
  |                                                                       
  |==========================                                       |  41%
  |                                                                       
  |===========================                                      |  41%
  |                                                                       
  |===========================                                      |  42%
  |                                                                       
  |============================                                     |  42%
  |                                                                       
  |============================                                     |  43%
  |                                                                       
  |============================                                     |  44%
  |                                                                       
  |=============================                                    |  44%
  |                                                                       
  |=============================                                    |  45%
  |                                                                       
  |==============================                                   |  45%
  |                                                                       
  |==============================                                   |  46%
  |                                                                       
  |==============================                                   |  47%
  |                                                                       
  |===============================                                  |  47%
  |                                                                       
  |===============================                                  |  48%
  |                                                                       
  |================================                                 |  49%
  |                                                                       
  |================================                                 |  50%
  |                                                                       
  |=================================                                |  50%
  |                                                                       
  |=================================                                |  51%
  |                                                                       
  |==================================                               |  52%
  |                                                                       
  |==================================                               |  53%
  |                                                                       
  |===================================                              |  53%
  |                                                                       
  |===================================                              |  54%
  |                                                                       
  |===================================                              |  55%
  |                                                                       
  |====================================                             |  55%
  |                                                                       
  |====================================                             |  56%
  |                                                                       
  |=====================================                            |  56%
  |                                                                       
  |=====================================                            |  57%
  |                                                                       
  |=====================================                            |  58%
  |                                                                       
  |======================================                           |  58%
  |                                                                       
  |======================================                           |  59%
  |                                                                       
  |=======================================                          |  59%
  |                                                                       
  |=======================================                          |  60%
  |                                                                       
  |=======================================                          |  61%
  |                                                                       
  |========================================                         |  61%
  |                                                                       
  |========================================                         |  62%
  |                                                                       
  |=========================================                        |  62%
  |                                                                       
  |=========================================                        |  63%
  |                                                                       
  |=========================================                        |  64%
  |                                                                       
  |==========================================                       |  64%
  |                                                                       
  |==========================================                       |  65%
  |                                                                       
  |===========================================                      |  65%
  |                                                                       
  |===========================================                      |  66%
  |                                                                       
  |===========================================                      |  67%
  |                                                                       
  |============================================                     |  67%
  |                                                                       
  |============================================                     |  68%
  |                                                                       
  |=============================================                    |  68%
  |                                                                       
  |=============================================                    |  69%
  |                                                                       
  |=============================================                    |  70%
  |                                                                       
  |==============================================                   |  70%
  |                                                                       
  |==============================================                   |  71%
  |                                                                       
  |===============================================                  |  72%
  |                                                                       
  |===============================================                  |  73%
  |                                                                       
  |================================================                 |  73%
  |                                                                       
  |================================================                 |  74%
  |                                                                       
  |================================================                 |  75%
  |                                                                       
  |=================================================                |  75%
  |                                                                       
  |=================================================                |  76%
  |                                                                       
  |==================================================               |  76%
  |                                                                       
  |==================================================               |  77%
  |                                                                       
  |==================================================               |  78%
  |                                                                       
  |===================================================              |  78%
  |                                                                       
  |===================================================              |  79%
  |                                                                       
  |====================================================             |  79%
  |                                                                       
  |====================================================             |  80%
  |                                                                       
  |====================================================             |  81%
  |                                                                       
  |=====================================================            |  81%
  |                                                                       
  |=====================================================            |  82%
  |                                                                       
  |======================================================           |  82%
  |                                                                       
  |======================================================           |  83%
  |                                                                       
  |======================================================           |  84%
  |                                                                       
  |=======================================================          |  84%
  |                                                                       
  |=======================================================          |  85%
  |                                                                       
  |========================================================         |  85%
  |                                                                       
  |========================================================         |  86%
  |                                                                       
  |========================================================         |  87%
  |                                                                       
  |=========================================================        |  87%
  |                                                                       
  |=========================================================        |  88%
  |                                                                       
  |==========================================================       |  89%
  |                                                                       
  |==========================================================       |  90%
  |                                                                       
  |===========================================================      |  90%
  |                                                                       
  |===========================================================      |  91%
  |                                                                       
  |============================================================     |  92%
  |                                                                       
  |============================================================     |  93%
  |                                                                       
  |=============================================================    |  93%
  |                                                                       
  |=============================================================    |  94%
  |                                                                       
  |=============================================================    |  95%
  |                                                                       
  |==============================================================   |  95%
  |                                                                       
  |==============================================================   |  96%
  |                                                                       
  |===============================================================  |  96%
  |                                                                       
  |===============================================================  |  97%
  |                                                                       
  |===============================================================  |  98%
  |                                                                       
  |================================================================ |  98%
  |                                                                       
  |================================================================ |  99%
  |                                                                       
  |=================================================================|  99%
  |                                                                       
  |=================================================================| 100%
plot(arctic_WA_cv$predicted[,1], arctic_WA_predict[,1])

arctic_WA_perf <- rioja::performance(arctic_WA)
arctic_WA_cv_perf <- rioja::performance(arctic_WA_cv)
arctic_WA_cv_perf
## $RMSE0
## [1] 3.54216
## 
## $object
##            RMSE        R2      Avg.Bias Max.Bias    Skill
## WA.inv 2.163844 0.6268224 -6.351707e-16 5.105933 62.68224
## WA.cla 2.733089 0.6268224 -5.405017e-15 3.354266 40.46518
## 
## $crossval
##            RMSE        R2    Avg.Bias Max.Bias    Skill
## WA.inv 2.179756 0.6213157 0.001413862 5.197317 62.13140
## WA.cla 2.745448 0.6219778 0.003391045 3.497582 39.92552

The performance statistics are overall very similar. The average bias for the cross-validated model is higher.

# Compare your MAT based reconstruction (week 8) to a WA based reconstruction of the same enironmental variable for the same site.

# Plot WA results
plot(arctic_WA)
title(main = "Arctic Pollen WA")

# Downloads modern pollen and climate data
data(Pollen)
data(Climate)

# Assigns climate variables to vectors
t_max <- Climate[,26]
# Cleans counts
Pollen_corrected <- replace(Pollen,is.na(Pollen),0)
# Calculates pollen percentages
Pollen_percentages <- 100*(Pollen_corrected/rowSums(Pollen_corrected))

# Runs MAT on modern pollen percentages and max temp
MAT.t_max <- rioja::MAT(Pollen_percentages, t_max, lean = FALSE)
## Warning in rioja::MAT(Pollen_percentages, t_max, lean = FALSE): Inter-sample distances < 1.0E-6 found (duplicate samples?
## These have been replaced by 1.0E-6
# Plots MAT results
plot(MAT.t_max)
title(main = "Arctic Pollen MAT")

# cross-validates the MAT using the leave-one-out technique
cv.tmax.mat.model <- rioja::crossval(MAT.t_max, cv.method='lgo', verbose=FALSE)
cv.tmax.mat.model
## 
## Method : Modern Analogue Technique
## Call   : MAT(y = y, x = x, dist.method = "sq.chord", k = 5, lean = FALSE) 
## 
## Distance : sq.chord 
## No. samples        : 4833 
## No. species        : 134 
## Cross val.         : lgo : no. groups =  10 
## 
## 
## Performance:
##                RMSE      R2  Avg.Bias  Max.Bias    Skill
## N01          2.1141  0.8631   -0.0325    2.3925  85.8239
## N02          1.8764  0.8893   -0.0349    2.8825  88.8321
## N03          1.8253  0.8947   -0.0327    3.0750  89.4329
## N04          1.8245  0.8946   -0.0470    3.0513  89.4418
## N05          1.8325  0.8937   -0.0550    3.0790  89.3496
## N01.wm       2.1141  0.8631   -0.0325    2.3925  85.8239
## N02.wm       1.8580  0.8914   -0.0373    2.8148  89.0502
## N03.wm       1.7919  0.8985   -0.0340    3.0375  89.8155
## N04.wm       1.7825  0.8994   -0.0469    3.0139  89.9221
## N05.wm       1.7798  0.8997   -0.0554    3.0334  89.9534
## N01_XVal     2.1385  0.8596   -0.0562    2.3675  85.4949
## N02_XVal     1.9010  0.8864   -0.0318    2.9163  88.5376
## N03_XVal     1.8572  0.8911   -0.0487    2.9417  89.0595
## N04_XVal     1.8463  0.8921   -0.0479    2.9719  89.1883
## N05_XVal     1.8481  0.8918   -0.0567    2.8695  89.1676
## N01.wm_XVal  2.1385  0.8596   -0.0562    2.3675  85.4949
## N02.wm_XVal  1.8829  0.8885   -0.0379    2.8615  88.7548
## N03.wm_XVal  1.8226  0.8951   -0.0501    2.9130  89.4642
## N04.wm_XVal  1.8057  0.8968   -0.0508    2.9460  89.6580
## N05.wm_XVal  1.7956  0.8979   -0.0587    2.8476  89.7732
# Determines RMSE, performance statistics, and cross-validated predictions' performance
perf.cv.tmax.mat.model <- rioja::performance(cv.tmax.mat.model)
perf.cv.tmax.mat.model
## $RMSE0
## [1] 5.61502
## 
## $object
##            RMSE        R2    Avg.Bias Max.Bias    Skill
## N01    2.114118 0.8630960 -0.03252638 2.392500 85.82393
## N02    1.876448 0.8892978 -0.03485413 2.882500 88.83213
## N03    1.825280 0.8947197 -0.03265742 3.075000 89.43289
## N04    1.824513 0.8946198 -0.04704635 3.051250 89.44176
## N05    1.832459 0.8936511 -0.05501345 3.079000 89.34960
## N01.wm 2.114118 0.8630960 -0.03252638 2.392500 85.82393
## N02.wm 1.858038 0.8914389 -0.03734852 2.814839 89.05018
## N03.wm 1.791929 0.8984843 -0.03396247 3.037489 89.81551
## N04.wm 1.782531 0.8993890 -0.04687621 3.013941 89.92206
## N05.wm 1.779758 0.8996679 -0.05541570 3.033404 89.95339
## 
## $crossval
##            RMSE        R2    Avg.Bias Max.Bias    Skill
## N01    2.138512 0.8596398 -0.05617629 2.367500 85.49490
## N02    1.901032 0.8863952 -0.03183323 2.916250 88.53758
## N03    1.857250 0.8911101 -0.04865853 2.941667 89.05948
## N04    1.846283 0.8921158 -0.04793606 2.971875 89.18830
## N05    1.848052 0.8918281 -0.05665218 2.869500 89.16757
## N01.wm 2.138512 0.8596398 -0.05617629 2.367500 85.49490
## N02.wm 1.882936 0.8885027 -0.03792799 2.861488 88.75476
## N03.wm 1.822572 0.8950587 -0.05014030 2.913006 89.46421
## N04.wm 1.805730 0.8967768 -0.05080119 2.945995 89.65804
## N05.wm 1.795646 0.8978703 -0.05870765 2.847611 89.77322

The MAT model is much more tightly grouped along a one-to-one line than the WA.